package com.hbl.xyl;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class AppReflect {
    public static void main(String[] args)throws Exception{
        Class<?>A=Class.forName("com.hbl.xyl.Animal");
        Object o=A.newInstance();
        Field[]  fields=A.getDeclaredFields();
        for(Field field:fields){
            field.setAccessible(true);
            Class<?>type=field.getType();
            if(type.toString().endsWith("String")){
                field.set(o,"hhh");
            }
            else if (type.toString().endsWith("Integer")){
                field.set(o,19);
            }
            else if (type.toString().endsWith("Double")){
                field.set(o,60.2);
            }
        }
        Method say=A.getDeclaredMethod("say");
        say.invoke(o);

    }
}
